package com.cindata

class BatchMortgage {

    Mortgage mortgage

    Date createdDate = new Date()
    Date modifiedDate = new Date()
    User createBy
    User modifyBy

    static belongsTo = [abnormalMortgageBatch: AbnormalMortgageBatch]

    static mapping = {
        autowire true
    }

    static constraints = {
      createdDate nullable: true, blank: true
      modifiedDate nullable: true, blank: true
      createBy nullable: true, blank: true
      modifyBy nullable: true, blank: true
    }

    def springSecurityService

    def beforeInsert()
    {
        def username = springSecurityService?.getPrincipal()?.username
        createBy = User.findByUsername(username)
    }

    def beforeUpdate()
    {
        modifiedDate = new Date()
        def username = springSecurityService?.getPrincipal()?.username
        modifyBy = User.findByUsername(username)
    }
}
